using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace IceAge
{
    public partial class Login : Form
    {
        public Login()
        {
            InitializeComponent();
        }
        public string UserId
        {
            get
            {
                return txtUsername.Text;
            }
        }

        private void btnClose_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void btnLogin_Click(object sender, EventArgs e)
        {
            try
            {
                //CenturyFox.Service data_access = new CenturyFox.Service();
                //string role = CommonLibrary.DoExecute("0101", new object[2] {"hoanvk", "kijuto" }).ToString();
                txtUsername.Text.Replace("=", string.Empty).Replace(">", string.Empty).Replace("<", string.Empty).Replace(")", string.Empty).Replace("(", string.Empty);
                string roles = CommonLibrary.GetStringFromProcedure(
                    "p_sel_UserLogin", "'" + txtUsername.Text + "','" +
                        CommonLibrary.MD5CryptPassword(txtPassword.Text) +"'");
                if (Convert.ToInt16(roles) > 0)
                {
                    this.DialogResult = DialogResult.OK;
                    this.Close();
                }
                else
                    MessageBox.Show("Ten nguoi su dung hoac mat khau khong dung, hay thu dang nhap lai!",
                   this.Text, MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString(), this.Text, MessageBoxButtons.OK, MessageBoxIcon.Error); 
            }
            
        }
    }
}